import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/transfer`

export function getTransferTaskList(params) {
  return request.get(`${AUTH_PREFIX_V1}/tasks`, { params }).then(res => camelCaseObject(res))
}

export function getTransferTaskListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/tasks/page`, { params }).then(res => camelCaseObject(res))
}

export function getTransferTask(taskId) {
  return request.get(`${AUTH_PREFIX_V1}/tasks/${taskId}`).then(res => camelCaseObject(res))
}

export function createTransferTask(params) {
  return request.post(`${AUTH_PREFIX_V1}/tasks`, params).then(res => camelCaseObject(res))
}

export function updateTransferTask(taskId, params) {
  return request.put(`${AUTH_PREFIX_V1}/tasks/${taskId}`, params).then(res => camelCaseObject(res))
}

export function executeTransferTask(taskId, params) {
  return request.put(`${AUTH_PREFIX_V1}/tasks/${taskId}/execute`, params).then(res => camelCaseObject(res))
}

export function deleteTransferTask(taskId) {
  return request.delete(`${AUTH_PREFIX_V1}/tasks/${taskId}`).then(res => camelCaseObject(res))
}
